home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 38 / Amiga Format CD38 (1999-03-15)(Future Publishing)(GB)(Track 1 of 3)[!][issue 1999-04].iso / -seriously_amiga- / programming / other / hrtmon / src / copper.s < prev    next >
Text File  |  1999-01-29  |  6KB  |  303 lines

  1.  
  2. ;HRTmon Amiga system monitor
  3. ;Copyright (C) 1991-1998 Alain Malek Alain.Malek@cryogen.com
  4. ;
  5. ;This program is free software; you can redistribute it and/or
  6. ;modify it under the terms of the GNU General Public License
  7. ;as published by the Free Software Foundation; either version 2
  8. ;of the License, or (at your option) any later version.
  9. ;
  10. ;This program is distributed in the hope that it will be useful,
  11. ;but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. ;GNU General Public License for more details.
  14. ;
  15. ;You can find the full GNU GPL online at: http://www.gnu.org
  16.  
  17. ;-------------- Search copper-list -----------------------------
  18.  
  19. cmd_cop        moveq    #0,d5
  20.         move.l    max_chip,d6
  21.         bsr    evaluate
  22.         bmi.w    illegal_addr
  23.         bgt.w    .norange
  24.         move.l    d0,d5
  25.         and.w    #$fffe,d5
  26.         bsr    evaluate
  27.         bmi.w    illegal_addr
  28.         bgt.w    .norange
  29.         move.l    d0,d6
  30.         and.w    #$fffe,d6
  31. .norange    cmp.l    d5,d6
  32.         bls.w    illegal_addr
  33.  
  34.         move.l    d5,a0
  35.         move.l    d6,a1
  36.         bsr    search_cop
  37.         tst.l    d7
  38.         beq.b    .cop
  39.  
  40.         lea.l    copfailed_txt(pc),a0
  41.         bsr    print
  42.         bra.b    .out
  43.  
  44. .cop        lea.l    copfound_txt(pc),a0
  45.         bsr    print
  46.         moveq    #8,d1
  47.         move.l    custom+$80,d0
  48.         bsr    print_hexCR
  49.  
  50. .out        bra.w    end_command
  51.  
  52. copfailed_txt    dc.b "Couldn't find copper-list",$a,0
  53. copfound_txt    dc.b "Copper-list found at $",0
  54.         even
  55.  
  56.  
  57. ;-> a0-a1 = search range
  58. ;<- d0 = copper address
  59. ;<- d7 = success / failed
  60.  
  61. search_cop    movem.l    d1/a2-a3,-(a7)
  62.         bsr    remove_pic
  63.         move.w    #$8380,$dff096
  64.         move.w    #$2700,sr
  65.  
  66.         bsr    find_cop_int
  67.  
  68.         moveq    #-1,d7
  69.  
  70.         moveq    #-2,d1
  71. .seek        cmp.l    a1,a0
  72.         bge.w    .end
  73.         cmp.l    (a0),d1
  74.         beq.b    .try
  75.         addq.l    #2,a0
  76.         bra.b    .seek
  77.  
  78. .try        move.l    a0,a2
  79.         addq.l    #2,a0
  80.  
  81.         move.l    a2,a3
  82.         subq.l    #4,a2
  83.         bsr    .test_cop
  84.         beq.b    .seek
  85.  
  86. .up        lea.l    -$200(a2),a2
  87.         cmp.l    #0,a2
  88.         bge.b    .okmin
  89.         suba.l    a2,a2
  90.         bra.b    .down
  91. .okmin        bsr    .test_cop
  92.         bne.b    .up
  93.  
  94. .down        lea.l    $20(a2),a2
  95.         cmp.l    a3,a2
  96.         ble.b    .okmax
  97.         move.l    a3,a2
  98.         bra.b    .up2
  99. .okmax        bsr    .test_cop
  100.         beq.b    .down
  101.  
  102. .up2        subq.l    #4,a2
  103.         bsr    .test_cop
  104.         bne.b    .up2
  105.  
  106.         addq.l    #4,a2
  107.  
  108.         moveq    #0,d7
  109.         move.l    a2,d0
  110.         move.l    d0,custom+$80
  111.  
  112. .end        move.l    d0,-(a7)
  113.         moveq    #0,d0
  114.         jsr    analyse_copper
  115.         move.l    (a7)+,d0
  116.  
  117.         bsr    set_pic
  118.         move.w    #$80,$dff096
  119.         move.w    #$7fff,$dff09c
  120.         move.w    #$2000,sr
  121.         movem.l    (a7)+,d1/a2-a3
  122.         rts
  123.  
  124. .test_cop    movem.l    d0/d6,-(a7)
  125.  
  126.         move.w    (a2),d0
  127.         btst    #0,d0
  128.         beq.b    .move
  129.         cmp.b    #$f0,d0
  130.         bhi.b    .nocop
  131.         bra.b    .okwait
  132. .move        tst.w    d0
  133.         beq.b    .nocop
  134.         cmp.w    #$1fe,d0
  135.         bls.b    .okwait
  136. .nocop        moveq    #0,d0
  137.         bra.b    .exittest
  138.  
  139. .okwait        move.w    cop_int(pc),$dff09c
  140.         move.l    (a2),d6
  141.         move.l    #$009c8000,d0
  142.         or.w    cop_int(pc),d0
  143.         move.l    d0,(a2)
  144. ;        move.w    #$0,$dff088
  145.         move.b    #0,$bfe801
  146. .wait        cmp.b    #2,$bfe801
  147.         bls.b    .wait
  148.         move.w    $dff01e,d0
  149.         move.l    d6,(a2)
  150.         and.w    cop_int(pc),d0
  151. .exittest    movem.l    (a7)+,d0/d6
  152.         rts
  153.  
  154. cop_int        dc.w 0
  155.  
  156. ;-------------- find a 'free' interrupt for copper searching -----
  157.  
  158. find_cop_int    movem.l    d0-d1/a0,-(a7)
  159.         move.w    #$10,d1            ;copint
  160.         bsr.b    .test
  161.         beq.b    .ok_int
  162.  
  163.         move.w    #4,d1            ;softint
  164.         bsr.b    .test
  165.         beq.b    .ok_int
  166.  
  167.         lea.l    .warning_txt(pc),a0
  168.         bsr    print
  169.  
  170. .ok_int        move.w    d1,cop_int
  171.         movem.l    (a7)+,d0-d1/a0
  172.         rts
  173.  
  174. .test        move.w    d1,$dff09c
  175. ;        move.w    #$0,$dff088
  176.         move.b    #0,$bfe801
  177. .wait        cmp.b    #2,$bfe801
  178.         bls.b    .wait
  179.         move.w    $dff01e,d0
  180.         and.w    d1,d0
  181.         rts
  182.  
  183. .warning_txt    dc.b "Couldn't find a free interrupt !",$a,0
  184.         even
  185.  
  186. ;----------------------------------------------------------
  187. ;-------------- analyse the actual copper-list and --------
  188. ;-------------- update custom registers -------------------
  189.  
  190. ;-> d0=pic_no (stop the scan after the d0th write to $DFF100, 0=scan all)
  191.  
  192. analyse_copper    movem.l    d0-a4,-(a7)
  193.         move.w    d0,d6
  194.         bne.b    .okpara
  195.         moveq    #-1,d6
  196. .okpara        lea.l    custom,a3
  197.         move.l    $80(a3),d0    ;get copper 1 start
  198.         bsr.b    .analyse
  199.         movem.l    (a7)+,d0-a4
  200.         rts
  201.  
  202.  
  203. ;-> d0=ptr on copper-list
  204.  
  205. .analyse    lea.l    custom,a3
  206.         lea.l    paletteH-$180,a1
  207.         move.w    ($106,a3),d3
  208.         btst    #9,d3        ;low or high bits palette
  209.         beq.b    .high
  210.         lea.l    paletteL-$180,a1
  211. .high        rol.w    #3,d3
  212.         and.w    #%111,d3    ;d1=bank no.
  213.         lsl.w    #6,d3        ;*32*2
  214.         add.w    d3,a1
  215.  
  216.         lea.l    move_list,a2
  217.         btst    #0,d0
  218.         bne.w    .end        ;copper list at odd address ?
  219.         move.l    d0,a0
  220.  
  221. .loop        move.l    a0,a4
  222.         bsr    reloc_pic
  223.         movem.w    (a4)+,d0/d1    ;read actual instr.
  224.         addq.l    #4,a0        ;go next instr.
  225.         btst    #0,d0        ;wait/skip or move instr. ?
  226.         bne.b    .waitinst
  227.  
  228.         cmp.w    #$200,d0    ;legal custom register ?
  229.         bcc.w    .end
  230.  
  231.         cmp.w    #$88,d0        ;cop1jmp ?
  232.         bne.b    .nojmp1
  233.         move.l    ($80,a3),a0    ;do the jmp to cop1
  234.         bra.b    .loop
  235. .nojmp1        cmp.w    #$8a,d0        ;cop2jmp ?
  236.         bne.b    .nojmp2
  237.         move.l    ($84,a3),a0    ;do the jmp to cop2
  238.         bra.b    .loop
  239.  
  240. .nojmp2        cmp.w    #$180,d0
  241.         blt.b    .nocolor
  242.         cmp.w    #$1be,d0
  243.         bgt.b    .nocolor
  244.         move.w    d1,(a1,d0.w)    ;copy in actual palette bank
  245.  
  246. .nocolor    cmp.w    #$106,d0
  247.         bne.b    .nobplcon3
  248.  
  249.         lea.l    paletteH-$180,a1
  250.         move.w    d1,d3
  251.         btst    #9,d3        ;low or high bits palette
  252.         beq.b    .high2
  253.         lea.l    paletteL-$180,a1
  254. .high2        rol.w    #3,d3
  255.         and.w    #%111,d3    ;d1=bank no.
  256.         lsl.w    #6,d3        ;*32*2
  257.         add.w    d3,a1
  258.  
  259. .nobplcon3    move.w    d0,d2
  260.         lsr.w    #1,d2
  261.         tst.b    (a2,d2.w)    ;do I need to copy this value ?
  262.         beq.b    .nocopy
  263.         move.w    d1,(a3,d0.w)    ;copy in custom
  264.         cmp.w    #$100,d0
  265.         bne.b    .no100
  266.         subq.w    #1,d6        ;dec(pic_no)
  267.         beq.b    .end
  268. .no100        bra.b    .nocopy
  269.  
  270. .waitinst    cmp.w    #$ffff,d0
  271.         beq.b    .end
  272.  
  273. .nocopy        bra.w    .loop
  274.  
  275. .end        rts
  276.  
  277.         cnop 0,4
  278. ;-------------- flags signaling registers to copy ---------
  279. ;-------------- from copper-list to custom ----------------
  280.  
  281. move_list    dcb.b $40,0        ;$000-$07e
  282.         dc.b -1,-1        ;$80,$82    ;cop1
  283.         dc.b -1,-1        ;$84,$86    ;cop2
  284.         dc.b 0,0,0        ;$88,$8a,$8c
  285.         dc.b -1,-1,-1,-1    ;$8e,$90,$92,$94
  286.         dcb.b $25,0        ;$96-$de
  287.         dcb.b $10,-1        ;$e0-$fe
  288.         dcb.b 7,-1        ;$100-$10c
  289.         dcb.b 9,0        ;$10e-$11e
  290.         dcb.b $10,-1        ;$120-$13e
  291.         dcb.b $20,0        ;$140-$17e
  292.         dcb.b $20,-1        ;$180-$1be
  293.         dcb.b $d,0        ;$1c0-$1d8
  294.         dc.b 0            ;$1da
  295.         dc.b -1            ;$1dc
  296.         dc.b -1,-1,-1        ;$1de-$1e2
  297.         dc.b -1            ;$1e4
  298.         dcb.b $b,0        ;$1e6-$1fa
  299.         dc.b -1            ;$1fc
  300.         dc.b 0            ;$1fe
  301. move_end
  302.  
  303.